class Animal1:
    def __init__(self):
        print("animal1")
        self.age = 15

class Animal2:
    def __init__(self):
        print("animal1")
        self.age = 25

class Dog(Animal1,Animal2):
    pass

my_dog = Dog()
"""
    按照继承关系,因为子类没有__init__
    所以使用了继承的__init__
"""
print(my_dog.age)


#*****************************
"""
    如果重写了__init__,就会使用自身的
"""
class Cat(Animal1,Animal2):
    def __init__(self):
        self.name = "kitty"

my_cat = Cat()
"""
Traceback (most recent call last):
    ...
    print(my_cat.age)
          ^^^^^^^^^^
AttributeError: 'Cat' object has no attribute 'age'
因为我们重写了__init__方法,不再受继承影响
"""
# print(my_cat.age)
#kitty
print(my_cat.name)


#*********************
class Pig(Animal1,Animal2):
    """
        可以用super调用父类被覆盖的方法
    """
    def __init__(self):
        # 调用父类的__init__
        super().__init__()
        self.name = "peiqi"

"""
    输出结果animal1
"""
my_pig = Pig()